<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			function $$(id){
				return document.getElementById(id)
			}
			window.onload=function(){
				var cnv=$$("canvas")
				var cxt=cnv.getContext("2d")
				
				var myImg=new Image()
				myImg.src="img/2.jpeg"
				myImg.onload=function(){
//					var pattern=cxt.createPattern(myImg,"repeat")
					var pattern=cxt.createPattern(myImg,"repeat-x")
					cxt.fillStyle=pattern
					cxt.fillRect(0,0,cnv.width,cnv.height)
				}
			}
		</script>
	</head>
	<body>
		<canvas id="canvas" width="200"height="200" style="border: 1px dashed gray;"></canvas>
	</body>
</html>
